﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using qlqa.Delegate.UserDelegate;
using qlqa.Models.Form.TaiKhoanForm;
using qlqa.Models.LinQ;
using Webdiyer.WebControls.Mvc;

namespace qlqa.Controllers
{
    public class UserController : Controller
    {
        UserDelegate _userDelegate = new UserDelegate();
        #region Quản lý Use type     
        public ActionResult QuanLyLoaiTaiKhoan()
        {
         
            return View();
        }
        #endregion

        #region Quản lý Use type
        public ActionResult QuanLyTaiKhoan()
        {
            var form = new TaiKhoanForm();
            form.DrLoaiTaiKhoan = _userDelegate.BuildTaiKhoanSelectList(0);
            return View(form);
        }

        public ActionResult ListTaiKhoan(string timKiem, int? pageNumber)
        {
            var form = new TaiKhoanForm();
            var listTaiKhoan = _userDelegate.GetDanhSachUser(timKiem);
            form.DanhSachTaiKhoan = new PagedList<tb_User>(listTaiKhoan, pageNumber ?? 1, 10);
            return View(form);
        }

        public bool TaoTaiKhoan(tb_User taiKhoan)
        {
            var ketQua = _userDelegate.TaoUserType(taiKhoan);
            return ketQua;
        }

        public bool CapNhatTaiKhoan(tb_User taiKhoan)
        {
            var ketQua = _userDelegate.CapNhatUser(taiKhoan);
            return ketQua;
        }

        public bool XoaTaiKhoan(int taiKhoanId)
        {
            var ketQua = _userDelegate.XoaUser(taiKhoanId);
            return ketQua;
        }


        public JsonResult GetThongTinThucDon(int idTaiKhoan)
        {
            return Json(_userDelegate.GetThongTinUser(idTaiKhoan));
        }
        #endregion

    }
}
